package com.qd.pandaparkflow.context;

import com.qd.common.panda.domain.entity.rule.BaseRuleDTO;
import com.qd.pandaparkflow.dto.PerViewDTO;
import lombok.Data;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;

/**
 * @author sjk
 */
@Data
@Accessors(chain = true)
@ToString
public class PriceContext {

    /**
     * 订单号
     */
    private String orderNo;
    /**
     * 订单开始时间
     */
    private LocalDateTime startTime;
    /**
     * 订单结束时间
     */
    private LocalDateTime endTime;
    /**
     * 可用于计算的分钟数
     */
    private Long minutes;
    /**
     * 单次金额
     */
    private BigDecimal unitPrice;
    /**
     * 订单最终价格
     */
    private BigDecimal finalOrderPrice;
    /**
     * 步骤日志
     */
    private List<String> printLog;
    /**
     * 规则ID
     */
    private String billRule;
    /**
     * 规则
     */
    private List<BaseRuleDTO> rules;
    /**
     * 是否能够下一步
     */
    private boolean hasNextStep;
    /**
     * 按次计算
     */
    private PerViewDTO perView;

    public void freeData() {
        this.orderNo = null;
        this.startTime = null;
        this.endTime = null;
        this.finalOrderPrice = null;
        this.printLog = null;
        this.minutes = null;
        Optional.ofNullable(this.rules).ifPresent(List::clear);
        this.billRule = null;
        Optional.ofNullable(this.perView).ifPresent(PerViewDTO::freeData);
    }
}
